<!--{eval $_TPL['titles'] = array($poll['subject'], '投票');}-->
<!--{template header}-->

<!--{if $space[self]}-->
<h2 class="title"><img src="image/app/poll.gif" />投票</h2>
<div class="tabs_header">
	<ul class="tabs">
		<li><a href="space.php?uid=$space[uid]&do=$do&view=new"><span>最新投票</span></a></li>
		<li><a href="space.php?uid=$space[uid]&do=$do&view=hot"><span>最热投票</span></a></li>
		<li><a href="space.php?uid=$space[uid]&do=$do&view=reward"><span>悬赏投票</span></a></li>
		<!--{if $space[friendnum]}--><li$actives[friend]><a href="space.php?uid=$space[uid]&do=$do&view=friend"><span>好友投票</span></a></li><!--{/if}-->
		<li class="active"><a href="space.php?uid=$space[uid]&do=$do&view=me"><span>我的投票</span></a></li>
		<li class="null"><a href="cp.php?ac=poll">发表新投票</a></li>
	</ul>
	<!--{if $_SGLOBAL[refer]}-->
	<div class="r_option">
		<a  href="$_SGLOBAL[refer]">&laquo; 返回上一页</a>
	</div>
	<!--{/if}-->
</div>
<!--{else}-->
<!--{eval
	$_TPL['spacetitle'] = "投票";
	$_TPL['spacemenus'][] = "<a href=\"space.php?uid=$space[uid]&do=$do&view=me\">TA的所有投票</a>";
	$_TPL['spacemenus'][] = "<a href=\"space.php?uid=$space[uid]&do=poll&pid=$pid\">查看投票详情</a>";
}-->
<!--{template space_menu}-->
<!--{/if}-->

<div id="content">
	<div class="poll_header">
		<div class="floatleft">
			<p>发起时间: <!--{date('Y-m-d H:i',$poll[dateline],1)}--></p>
			<p>参与人数: <strong>$poll[voternum]</strong> 人</p>
			<!--{if $space[self] && $poll[credit]}-->
			<p>剩余悬赏: <strong>$poll[credit]</strong></p>
			<!--{/if}-->
			<!--{if $poll[expiration]}--><p>截止时间: <!--{date('Y-m-d',$poll[expiration])}--></p><!--{/if}-->
		</div>
		<!--{if $space[self]}-->
		<div class="floatright">
			<script type="text/javascript" src="source/script_calendar.js"></script>
			<!--{if $poll[credit]}-->
			<p><a href="cp.php?ac=poll&op=endreward&pid=$poll[pid]" id="poll_reward_$poll[pid]" onclick="ajaxmenu(event, this.id)">终止悬赏</a></p>
			<!--{/if}-->
			<p><a href="cp.php?ac=poll&op=addreward&pid=$poll[pid]" id="add_new_reward" onclick="ajaxmenu(event, this.id)">追加悬赏</a></p>
			<p><a href="cp.php?ac=poll&op=addopt&pid=$poll[pid]" id="addnewoption" onclick="ajaxmenu(event, this.id, 1)">增加候选项</a></p>
			<p><a href="cp.php?ac=poll&pid=$poll[pid]&op=delete" id="poll_delete_$poll[pid]" onclick="ajaxmenu(event, this.id)">删除本投票</a></p>
			<p><a href="cp.php?ac=poll&pid=$poll[pid]&op=modify" id="poll_modify_$poll[pid]" onclick="ajaxmenu(event, this.id)">修改截止时间</a></p>
			<p><a href="cp.php?ac=poll&pid=$poll[pid]&op=summary" id="poll_summary_$poll[pid]" onclick="ajaxmenu(event, this.id, 1)">写写投票总结</a></p>
		</div>
		<!--{else}-->

		<!--{/if}-->
	</div>

	<div class="poll_title">
		<!--{if $expiration}-->
		<div class="print overtime">[过期]</div>
		<!--{elseif $poll[percredit]}-->
		<div class="print guerdon">[悬赏]</div>
		<!--{/if}-->
		<!--{if $poll[hot]}--><span class="hot"><em>热</em>$poll[hot]</span><!--{/if}--><h3><img src="image/poll_icon.gif" /> $poll[subject]</h3><!--{if $poll['sex'] && $poll['sex'] != $_SGLOBAL['member']['sex'] || $poll[multiple]}--> (<!--{if $poll['sex'] && $poll['sex'] != $_SGLOBAL['member']['sex']}-->仅限<strong><!--{if $poll['sex']==1}-->男<!--{else}-->女<!--{/if}--></strong>性参与 <!--{/if}--><!--{if $poll[multiple]}-->最多可选{$poll[maxchoice]}项<!--{/if}-->) <!--{/if}-->
		<!--{if $_GET[reward]}-->
		<p style="color: #F30">恭喜您获得  <strong>$_GET[reward]</strong> 个积分</p>
		<!--{elseif $poll[percredit]}-->
		<p style="color: #F30">投票将获得 <strong>$poll[percredit]</strong> 个积分</p>
		<!--{/if}-->
	</div>
	<!--{if $poll[message]}--><p class="poll_depiction">$poll[message]</p><!--{/if}-->

	<form name="poll" method="post" action="cp.php?ac=poll&pid=$poll[pid]&op=vote">

	<ol class="poll_item_list">
		<!--{eval $bcid = rand(0, 19);}-->
		<!--{loop $option $key $val}-->
		<li>
			<label class="poll_item">$val[option]:</label>
			<!--{if $bcid>19}-->
			<!--{eval $bcid=$bcid-19}-->
			<!--{/if}-->
			<div class="bar_bg bc_$bcid">
				<div class="bar_left"></div>
				<div class="bar_middle" id="bar_$key" len="{$val[width]}"></div>
				<div class="bar_right"></div>
			</div>
			<!--{eval $bcid++;}-->
			<div class="poll_percent">$val[votenum] ($val[percent]%)</div>
			<div class="floatleft">
				<!--{if $allowedvote && !$hasvoted}-->
				<input type="<!--{if $poll[multiple]}-->checkbox<!--{else}-->radio<!--{/if}-->" name="option[]" value="$val[oid]" <!--{if $poll[multiple]}-->onclick="checkSelect(this.checked)"<!--{/if}-->/>
				<!--{/if}-->
			</div>
		</li>
		<!--{/loop}-->
	</ol>
	<div class="poll_submit">
		<!--{if $allowedvote && !$hasvoted}-->
		<input type="hidden" name="votesubmit" value="true" />
		<input type="submit"  class="submit" id="votebutton" name="votebutton" value="投票" /><br />
		<label><input type="checkbox" name="anonymous" value="1"> 匿名投票</label>
		<input type="hidden" name="formhash" value="<!--{eval echo formhash();}-->" />
		<!--{/if}-->
	</div>

	</form>

	<!--{if $poll[summary]}-->
	<div class="poll_summary">
	<h3 class="poll_sumuptitle">{$_SN[$poll[uid]]}对该投票的总结</h3>
	<p class="poll_sumup">$poll[summary]</p>
	</div>
	<!--{/if}-->

	<div class="poll_htitle">

	<a href="cp.php?ac=share&type=poll&id=$poll[pid]" id="a_share" onclick="ajaxmenu(event, this.id, 1)" class="a_share">分享</a>
		<div class="r_option">
			<!--{if $_SGLOBAL[supe_uid] == $poll[uid] || checkperm('managepoll')}-->
			<a href="cp.php?ac=topic&op=join&id=$poll[pid]&idtype=pid" id="a_topicjoin_$poll[pid]" onclick="ajaxmenu(event, this.id)">凑热闹</a><span class="pipe">|</span>
			<a href="admincp.php?ac=poll&pid=$poll[pid]" target="_blank">删除</a><span class="pipe">|</span>
			<!--{/if}-->
			<!--{if checkperm('managepoll')}-->
			<a href="cp.php?ac=poll&pid=$poll[pid]&op=edithot" id="a_hot_$poll[pid]" onclick="ajaxmenu(event, this.id)">热度</a><span class="pipe">|</span>
			<!--{/if}-->
			<a href="cp.php?ac=common&op=report&idtype=pid&id=$poll[pid]" id="a_report" onclick="ajaxmenu(event, this.id, 1)">举报</a><span class="pipe">|</span>
			<a href="cp.php?uid=$poll[uid]&ac=poll&op=invite&pid=$poll[pid]"/>邀请好友</a><span class="pipe">|</span>
		</div>
		<div class="custom">
		<a id="newvoter" href="javascript:;" onclick="showVoter('new');">最新投票</a>
		<a id="wevoter" href="javascript:;" onclick="showVoter('we');">好友投票</a>
		</div>
	</div>
	<div id="showvoter"></div>
	<script type="text/javascript">
		<!--{if !$hasvoted}-->
		var maxSelect = $poll[maxchoice];
		var alreadySelect = 0;
		function checkSelect(sel) {
			if(sel) {
				alreadySelect++;
				if(alreadySelect == maxSelect) {
					var oObj = document.getElementsByName("option[]");
					for(i=0; i < oObj.length; i++) {
						if(!oObj[i].checked) {
							oObj[i].disabled = true;
						}
					}
				}
			} else {
				alreadySelect--;
				if(alreadySelect < maxSelect) {
					var oObj = document.getElementsByName("option[]");
					for(i=0; i < oObj.length; i++) {
						if(oObj[i].disabled) {
							oObj[i].disabled = false;
						}
					}
				}
			}
		}
		<!--{/if}-->

		//效查
		var optionNum = <!--{eval echo count($option)}-->;
		var maxLength = [0,1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,16,17,18,19];

		var timer;
		var length = 0;
		for(i = 0; i < optionNum; i++) {
			maxLength[i] = $("bar_" + i).getAttribute('len');
		}
		timer = setInterval(function(){
			setLength();
		}, 40);
		function setLength(){
			for (i = 0; i < optionNum; i++) {
				if (length - 1 >= maxLength[i]) {
					$('bar_' + i).style.width = maxLength[i] + "px";
				} else {
					$('bar_' + i).style.width = length + "px";
				}
				length = length + 1;
				if (length > 300) {
					clearInterval(timer);
				}
			}
		}
		function showVoter(filtrate) {
			$('newvoter').className = '';
			$('wevoter').className = '';
			$(filtrate+'voter').className = 'active';
			ajaxget('cp.php?ac=poll&op=get&pid=$poll[pid]&filtrate='+filtrate, 'showvoter');
		}
		showVoter('new')
	</script>
	<!--{if $isfriend}-->
	<div class="comments" id="div_main_content" style="padding: 0 0 20px;">

		<h3 class="feed_header"> <div class="r_option"><span id="comment_replynum">$poll[replynum]</span> 个评论</div>评论</h3>
		<div class="page">$multi</div>
		<div class="comments_list" id="comment">
			<!--{if $cid}-->
			<div class="notice">
				当前只显示与你操作相关的单个评论，<a href="space.php?uid=$poll[uid]&do=poll&pid=$poll[pid]">点击此处查看全部评论</a>
			</div>
			<!--{/if}-->
			<ul id="comment_ul">
			<!--{loop $list $value}-->
				<!--{template space_comment_li}-->
			<!--{/loop}-->
			</ul>
		</div>
		<div class="page">$multi</div>

		<form id="quickcommentform_{$pid}" name="quickcommentform_{$pid}" action="cp.php?ac=comment" method="post" class="quickpost">
			<table cellpadding="0" cellspacing="0">
				<tr>
					<td>
						<a href="###" id="face" title="插入表情" onclick="showFace(this.id, 'comment_message');return false;"><img src="image/facelist.gif" align="absmiddle" /></a>
						<!--{if $_SGLOBAL['magic']['doodle']}-->
						<a id="a_magic_doodle" href="magic.php?mid=doodle&showid=comment_doodle&target=comment_message" onclick="ajaxmenu(event, this.id, 1)"><img src="image/magic/doodle.small.gif" class="magicicon" />涂鸦板</a>
						<!--{/if}-->
						<br />
						<textarea id="comment_message" onkeydown="ctrlEnter(event, 'commentsubmit_btn');" name="message" rows="5" style="width:500px;"></textarea>
					</td>
				</tr>
				<tr>
					<td>
						<input type="hidden" name="refer" value="space.php?uid=$poll[uid]&do=$do&id=$pid" />
						<input type="hidden" name="id" value="$pid">
						<input type="hidden" name="idtype" value="pid">
						<input type="hidden" name="commentsubmit" value="true" />
						<input type="button" id="commentsubmit_btn" name="commentsubmit_btn" class="submit" value="评论" onclick="ajaxpost('quickcommentform_{$pid}', 'comment_add')" />
						<span id="__quickcommentform_{$pid}"></span>
					</td>
				</tr>
			</table>
			<input type="hidden" name="formhash" value="<!--{eval echo formhash();}-->" />
		</form><br />
	</div>
	<!--{/if}-->

</div>

<div id="sidebar">


	<!--{if $topic}-->
	<div class="affiche">
		<img src="image/app/topic.gif" align="absmiddle">
		<strong>凑个热闹</strong>：<a href="space.php?do=topic&topicid=$topic[topicid]">$topic[subject]</a>
	</div>
	<!--{/if}-->

	<div class="sidebox">
		<h2 class="title">最新投票</h2>
		<ul class="news_list poll_new">
			<!--{if $newpoll}-->
			<!--{loop $newpoll $key $value}-->
			<li style="height:auto;"><a href="space.php?uid=$value[uid]&do=$do&pid=$value[pid]">$value[subject]</a></li>
			<!--{/loop}-->
			<!--{else}-->
				<li style="height:auto;">暂时没有新投票</li>
			<!--{/if}-->
		</ul>
	</div>

	<div class="sidebox">
		<h2 class="title">最热投票</h2>
		<ul class="news_list poll_new">
			<!--{if $hotpoll}-->
				<!--{loop $hotpoll $key $value}-->
				<li style="height:auto;"><a href="space.php?uid=$value[uid]&do=$do&pid=$value[pid]">$value[subject]</a></li>
				<!--{/loop}-->
			<!--{else}-->
				<li style="height:auto;">暂时没有本月热门投票</li>
			<!--{/if}-->
		</ul>
	</div>

</div>

<script type="text/javascript">
//彩虹炫
var elems = selector('div[class~=magicflicker]'); 
for(var i=0; i<elems.length; i++){
	magicColor(elems[i]);
}
</script>

<!--{template footer}-->